# -*- coding: UTF-8 -*-
from django.contrib import admin
from django.utils.translation import gettext_lazy as _
from .models import Company, Department


@admin.register(Company)
class CompanyAdmin(admin.ModelAdmin):
    list_display = ['name', 'code', 'type', 'address', 'phone', 'email', 'created_at']
    list_display_links = ['name']
    search_fields = ['name', 'code', 'address']
    list_filter = ['type', 'created_at']
    date_hierarchy = 'created_at'
    
    fieldsets = (
        (_('基本信息'), {
            'fields': ('name', 'code', 'type', 'description')
        }),
        (_('联系信息'), {
            'fields': ('address', 'phone', 'email', 'website')
        }),
        (_('其他信息'), {
            'fields': ('note',),
            'classes': ('collapse',)
        }),
    )


@admin.register(Department)
class DepartmentAdmin(admin.ModelAdmin):
    list_display = ['name', 'code', 'company', 'parent', 'manager', 'created_at']
    list_display_links = ['name']
    search_fields = ['name', 'code', 'description']
    list_filter = ['company', 'parent', 'created_at']
    date_hierarchy = 'created_at'
    
    fieldsets = (
        (_('基本信息'), {
            'fields': ('name', 'code', 'company', 'parent')
        }),
        (_('管理信息'), {
            'fields': ('manager', 'description')
        }),
        (_('其他信息'), {
            'fields': ('note',),
            'classes': ('collapse',)
        }),
    ) 